home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Examples / Helpfile / StringRegExp.au3 < prev    next >
Text File  |  2007-09-08  |  1KB  |  42 lines

  1. ;Option 1, using offset
  2. $nOffset = 1
  3. While 1
  4.     $array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 1, $nOffset)
  5.     
  6.     If @error = 0 Then
  7.         $nOffset = @extended
  8.     Else
  9.         ExitLoop
  10.     EndIf
  11.     for $i = 0 to UBound($array) - 1
  12.         msgbox(0, "RegExp Test with Option 1 - " & $i, $array[$i])
  13.     Next
  14. WEnd
  15.  
  16.  
  17. ;Option 2, single return, php/preg_match() style
  18. $array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 2)
  19. for $i = 0 to UBound($array) - 1
  20.     msgbox(0, "RegExp Test with Option 2 - " & $i, $array[$i])
  21. Next
  22.  
  23.  
  24. ;Option 3, global return, old AutoIt style
  25. $array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 3)
  26.  
  27. for $i = 0 to UBound($array) - 1
  28.     msgbox(0, "RegExp Test with Option 3 - " & $i, $array[$i])
  29. Next
  30.  
  31.  
  32. ;Option 4, global return, php/preg_match_all() style
  33. $array = StringRegExp('F1oF2oF3o', '(F.o)*?', 4)
  34.  
  35. for $i = 0 to UBound($array) - 1
  36.  
  37. $match = $array[$i]
  38.     for $j = 0 to UBound($match) - 1
  39.         msgbox(0, "cRegExp Test with Option 4 - " & $i & ',' & $j, $match[$j])
  40.     Next
  41. Next
  42.